<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="zhcms.admin.*" %> 
<%@ page import="zhcms.framework.*" %> 
<%@ page import="zhcms.tool.*" %> 
<%@ include file="include/adminhead.jsp" %>
<%
request.setCharacterEncoding("utf-8");
String action=request.getParameter("atcion");
GyUserLoginValidate gycheck=new GyUserLoginValidate();
int ischeck=gycheck.UserLoginValidate(request, response);
if(ischeck==0)
{
		try{
			out.println("<script language='javascript'>alert('对不起！，您还没有登陆');location.href=\"index.jsp\";</script>");
		}
		catch(Exception e){
			e.printStackTrace();
		}
} 

%>
<script type="text/javascript" src="../xheditor/jquery/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../xheditor/xheditor-1.1.14-zh-cn.min.js"></script>
<TABLE width="100%" border="0" align="center" cellPadding="0" cellSpacing="0" class="sortbutton">
	<tr> 
	    <th width="100%" height="22" valign="middle"><a href="?">管理首页</a> | <a href="?atcion=add">新增</a>  </th>
	</tr>
</table>
<br>
<% 
if(action==null || action.length()<=0  || action.equals("main"))
{
String page1=request.getParameter("p");
int pageb;    //存储当前页码
if(page1==null)
   pageb=1;
else 
   pageb=Integer.parseInt(page1);
  
GyContent gyf=new GyContent();

int countnum=gyf.listcount();
%>
<table width="98%" border="0" cellpadding="0" cellspacing="0" align="center" class="TableBorder">
  <tr valign="middle" align="center" height="22"> 
    <th class=sort width="5%">Id</th>
    <th class=sort>标题</th>
    <th class=sort width="10%">栏目</th>
    <th class=sort width="10%">添加日期</th>
    <th class=sort width="10%">浏览数/大小</th>
    <th class=sort width="20%">操作</th>
  </tr>
<%
if(countnum>0)
{
String lybpages="";
ArrayList<HashMap<String, String>> gytInFor;
gytInFor=new ArrayList<HashMap<String, String>>();
gytInFor=gyf.getAllList(pageb);
lybpages=gyf.getPageStr();
for(int i=0;i<gytInFor.size();i++)
{
	Map<String,String> iAdmininfo=new HashMap<String,String>();
	iAdmininfo =gytInFor.get(i);
 %>
  <tr valign="middle" bgcolor="#FFFFFF" align="center" height="22"> 
    <td>&nbsp;<%=iAdmininfo.get("Id")%></td>
    <td align="left"><%=iAdmininfo.get("Title")%></td>
    <td><%=iAdmininfo.get("ColumnName")%></td>
    <td><%=iAdmininfo.get("AddDate")%></td>
    <td><font color=red><%=iAdmininfo.get("ViewNum")%></font> / <font color=green><%=iAdmininfo.get("Byte")%></font></td>
    <td><a href="?atcion=add&postid=<%=iAdmininfo.get("Id")%>">编辑</a> | <a href="/zhcms!admin!GyContent(del).do?postid=<%=iAdmininfo.get("Id")%>" onclick="{if(confirm('确定删除吗?')){return true;}return false;}">删除</a></td>
  </tr>
<%
}
 %>
  <tr valign="middle" bgcolor="#FFFFFF" align="right">
	<td colspan="6" height="22">&nbsp;<%=lybpages%></td>
  </tr>
 <%
 }
 else
 {
 %> <tr valign="middle" bgcolor="#FFFFFF">
	<td colspan="4" height="22">&nbsp;暂时没有任何信息！</td>
  </tr>
 <%
 } 
 %>
</table>
<%
}
else if(action.equals("add")) 
{
		
		String postid=request.getParameter("postid");
		
		String FromName="";
		String Title="";
   String Author="";
   String Content="";
   String KeyWord="";
   String ColumnId="";
   String TColor="";
   String IsImg="";
   String ImgPath="";
   String IsTop="";
		
		if(postid==null || postid.length()<=0)
		{
			
		}
		else
		{
			GyContent gyfk=new GyContent();
			ArrayList<HashMap<String, String>> gytFkOne;
			gytFkOne=new ArrayList<HashMap<String, String>>();
			gytFkOne=gyfk.getOneList(postid);
			if(gytFkOne.size()>0)
			{
				Map<String,String> iiContentLinkinfo=new HashMap<String,String>();
				iiContentLinkinfo=gytFkOne.get(0);
				Title=iiContentLinkinfo.get("Title");
   		Author=iiContentLinkinfo.get("Author");
   		Content=iiContentLinkinfo.get("Content");
   		KeyWord=iiContentLinkinfo.get("KeyWord");
   		ColumnId=iiContentLinkinfo.get("ColumnId");
   		TColor=iiContentLinkinfo.get("TColor");
   		IsImg=iiContentLinkinfo.get("IsImg");
   		ImgPath=iiContentLinkinfo.get("Img");
   		IsTop=iiContentLinkinfo.get("IsTop");
			}
			
		}
		
		%>

		<table width="80%" border="0" cellpadding="0" cellspacing="0" class=TableBorder align="center">
		  <form name="a1" id="a1"  method="post" action="/zhcms!admin!GyContent(save).do?postid=<%=postid%>">
		    <tr align="center" valign="middle"> 
      <th colspan="4" height="22">文章发布</th>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="13%" align="center">栏目</td>
      <td width="44%" align="left">&nbsp;<select name="ColumnCode">
      <option value=>根栏目</option>
      			<%
      			GyColumn gyc=new GyColumn();
      			ArrayList<HashMap<String, String>> gytFkOne;
							gytFkOne=new ArrayList<HashMap<String, String>>();
      			
      			gytFkOne=gyc.getAllList();
      			for(int i=0;i<gytFkOne.size();i++)
			      			{
			      		Map<String,String> iiColumninfo=new HashMap<String,String>();
			      		iiColumninfo=gytFkOne.get(i);
			      		int Level=0;
			      		Level=(iiColumninfo.get("ColumnCode").length()/4-1)*3;
			      		out.println("<option value="+iiColumninfo.get("Id")+"|||"+iiColumninfo.get("Name")+"|||"+iiColumninfo.get("ColumnCode"));
			      		if(ColumnId.equals(iiColumninfo.get("Id")))
									{
											out.println(" selected");
									}	      		
			      		out.println(">");
			      		
			      		if(iiColumninfo.get("ColumnCode").length()>4)
									 {
									 	out.println("├");
									 }
									
									for(int j=0;j<Level;j++)
									{
										out.println("-");
									}
									out.println(iiColumninfo.get("Name")+"</option>");
			      			}
      			 %>
        </select> <font color=red>*</font></td>
	  <td width="13%" align="right">作者</td>
      <td width="30%" align="left">&nbsp;
      <input name="Author" type="text" value="<%=Author%>"></td>
    </tr>
    <tr bgcolor="ffffff" valign="middle"> 
      <td align="center" width="13%">标题</td>
      <td align="left">&nbsp;<input name="Title" type="text" size=40 value="<%=Title%>"> <font color=red>*</font></td>
	  <td width="13%" align="right">标题颜色</td>
      <td align="left">&nbsp;<select name="TColor">
		  <option value="0" <% if(TColor.equals("0")){out.println(" selected ");}%>>普通</option>
		  <option value="1" <% if(TColor.equals("1")){out.println(" selected ");}%>>红色</option>
		  <option value="2" <% if(TColor.equals("2")){out.println(" selected ");}%>>绿色</option>
		  <option value="3" <% if(TColor.equals("3")){out.println(" selected ");}%>>蓝色</option>
	  </select></td>
    </tr>
    <tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="13%" align="center">关键字</td>
      <td align="left">&nbsp;<input name="KeyWord" size=40 type="text" value="<%=KeyWord%>">&nbsp;以,号分隔</td>
	  <td width="13%" align="right">头条推荐文章</td>
      <td align="left">&nbsp;<input type="checkbox" name="IsTop" value="1" <%
        						if(IsTop.equals("1"))
        									{
        										out.println(" checked ");
        									}
        		 %>></td>
    </tr>
	<tr bgcolor="#FFFFFF" valign="middle"> 
      <td width="13%" align="center">是否图片新闻</td>
      <td align="left"><input type="checkbox" name="IsImg" value="1" <%
        						if(IsImg.equals("1"))
        									{
        										out.println(" checked ");
        									}
        		 %>>&nbsp;<font color=red>选择此项即为图片新闻，建议大小为120*90</font></td>
      <td align="right">标题图片</td>
      <td align="left">&nbsp;<input name="ImgPath"  size=40 type="text" value="<%=ImgPath%>" readonly="true"><br />&nbsp;<iframe name="up" frameborder="0" width="400" height="30" scrolling="no" src="upload.jsp"></iframe><% 
      if(ImgPath==null || ImgPath.length()<=0) 
    		  { 
      		
		      } 
		  else
		      {
		      %>
      <a href="<%=ImgPath%>" target="_blank">预览图片</a>
		      <%
		      }
		 %></td>
    </tr>
    <tr bgcolor="ffffff" valign="middle"> 
      <td align="center" width="13%">正文</td>
      <td align="left" colspan="3">&nbsp;
<!-- <textarea id="content" name="content" class="xheditor" rows="12" cols="80" style="width: 80%">
<%=Content%>
</textarea> -->
<INPUT type="hidden" name="content" value="<%=GyHTMLEncode.htmlEncode(Content)%>">
<iframe id="eWebEditor1" src="../eWebEditorJSP/ewebeditor.htm?id=content&style=standard650&skin=office2003&originalfilename=myText1&savefilename=myText2&savepathfilename=myText3" frameborder="0" scrolling="no" width="650" height="350"></iframe>

</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td align="center" valign="middle" colspan="4"><input type="submit" name="Submit" value="更新">&nbsp;<input type="reset" name="Submit2" value="重置"></td>
    </tr>
		  </form>
		</table>
		<%
}
%>
<%@ include file="include/adminfoot.jsp" %>

